﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoolCode.Services;

namespace CoolCode.Web.Security
{
    class ServiceProvider
    {
        private static string _connectionString;

        private static MembershipService _service = null;

        private static readonly object lockobject = new object();

        public static void Initial(string connectionKey)
        {
            _connectionString = System.Configuration.ConfigurationManager.ConnectionStrings[connectionKey].ConnectionString; 
        }

        public static MembershipService Get()
        {
            if (_service == null)
            {
                lock (lockobject)
                {
                    if (_service == null)
                    {
                        //  _service = new MembershipService(_connectionString);
                        _service = new MembershipService();
                    }
                }
            }
            return _service;
        }
    }
}
